const _ = require('lodash');

module.exports = {
  schedule: {
    cron: '30 1/3 5-23 * * ?',
    type: 'worker',
    env: ['pachong'],
    // immediate: true
  },

  async task(ctx) {
    const r1 = await ctx.service.crawlerSvc.choutiFaxian();
    const r2 = await ctx.service.crawlerSvc.qqAll();

    const topics = r1
      .concat(r2)
    ;

    const shuffle_topics = _.shuffle(topics);
    let result = await ctx.service.topicSvc.importTopics(shuffle_topics);
    ctx.logger.info(`抽屉发现 ready ${topics.length} success ${result}`);
  }
};
